import { uploadFileService } from '../../../util/tenxunCos/index';

export default async function uploadFile(ctx: Context, next: Next): Promise<void> {
  const { files } = ctx.request as MyRequest;
  const { file } = files;

  try {
    const result = await uploadFileService(file);
    ctx.api.success(result, 'sucess');
  } catch (error) {
    ctx.api.fail(-1, error);
  }
  
  return next();
}